package com.xbongbong.saas.enums;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.pro.enums.PackageTypeEnum;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @ClassName TabTypeEnum
 * @Description 目标管理-页签tab
 * @Author mengna.Deng
 * @Date 2022/3/10 14:11
 * @Version 1.0
 */
@Getter
public enum TabTypeEnum {
    /*
     * 页签枚举
     */
    SYSTEM_PERFORMANCE(1, "enum.tabType.name.system_performance"),

    CUSTOM_PERFORMANCE(2, "enum.tabType.name.custom_performance"),

    ;

    /** 枚举描述 --英文名称*/
    private final Integer statisticsType;
    /** 枚举信息--中文名称 */
    private final String  name;

    TabTypeEnum(Integer statisticsType, String name) {
        this.statisticsType = statisticsType;
        this.name = name;
    }

    /**
     * 获取全部枚举
     *
     * @return List<AssessTypeEnum>
     */
    public static List<TabTypeEnum> getAllEnum() {
        List<TabTypeEnum> list = new ArrayList<>();
        for (TabTypeEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static JSONArray getByFeeType(Integer feeType){
        List<JSONObject> list = new ArrayList<>();

        JSONObject systemPerformance = new JSONObject();
        systemPerformance.put(StringConstant.STATISTICS_TYPE,SYSTEM_PERFORMANCE.getStatisticsType());
        systemPerformance.put(BasicConstant.NAME,SYSTEM_PERFORMANCE.getName());
        list.add(systemPerformance);

        if (Objects.equals(feeType, PackageTypeEnum.ULTIMATE.getType())){
            JSONObject customPerformance = new JSONObject();
            customPerformance.put(StringConstant.STATISTICS_TYPE,CUSTOM_PERFORMANCE.getStatisticsType());
            customPerformance.put(BasicConstant.NAME,CUSTOM_PERFORMANCE.getName());
            list.add(customPerformance);
        }
        return JSONArray.parseArray(JSON.toJSONString(list));
    }
}
